package co.edu.unal.geditor.controller.action.undoable.color;

import java.awt.Color;

import javax.swing.undo.AbstractUndoableEdit;
import javax.swing.undo.CannotRedoException;
import javax.swing.undo.CannotUndoException;

import co.edu.unal.geditor.controller.App;
import co.edu.unal.geditor.model.Drawing;

public class UndoableChangeBackgroundColorAction extends AbstractUndoableEdit {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public UndoableChangeBackgroundColorAction ()
		{	
			m_oldColor=App.getInstance().getDrawing().getcolorBackground();
		}

		public void undo() throws CannotUndoException
		{
			Drawing drawing = App.getInstance().getDrawing();
			m_newColor=drawing.getcolorBackground();
			drawing.setcolorBackground(m_oldColor);
		}

		public void redo() throws CannotRedoException
		{
			Drawing drawing = App.getInstance().getDrawing();
			
			drawing.setcolorBackground(m_newColor);
		}

		public boolean canUndo()
		{
			return (m_oldColor!= null);
		}

		public boolean canRedo()
		{
			return (m_newColor != null);
		}

		public String getPresentationName()
		{
			return "Change Background Color";
		}

		
		private Color m_oldColor;
		private Color m_newColor;
	}

